package demo.practice.dp;

public class P45 {

    public int jump(int[] nums) {


        int dp[] = new int[nums.length];
        dp[0] = 0; //本身就在索引为0的位置

        //转移方程式：dp[i]=Min(dp[j]+1) 当 nums[j]+j>=i

        for (int i = 1; i < nums.length; i++) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = 0; j < i; j++) {
                dp[i] = nums[j] + j >= i && dp[j] + 1 < dp[i] ? dp[j] + 1 : dp[i];
            }
        }
        return dp[nums.length-1];
    }
}
